﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HappyLearning
{
    class Linq
    {
        List<int> mylist = new List<int>();
        public void myList()
        {
            mylist.Add(1);
            mylist.Add(3);
            mylist.Add(9);
            mylist.Add(1);
            mylist.Add(3);
            mylist.Add(9);
            mylist.Add(1);
            mylist.Add(3);
            mylist.Add(9);

        }

        public List<int> meetsCondition()
        {
            List<int> result = new List<int>();
            result = (from p in mylist
                         where p == 1
                         select p).ToList<int>();
            return result;
        }

        public int firstElementMeetsCondition()
        {

            int result = (from p in mylist
                          where p == 1
                          select p).First<int>();
            return result;
        }

    }
}
